// 我要拿的数据
var data = {
    imgUrl: "https://openfile.meizu.com/group1/M00/07/E5/Cgbj0V61DmKAarkmAAUGRp7cOD4317.png",
    name: "魅族 17 航母限定版",
    desc: "以梦为舰 热爱起航",
    price: "4299",
    red: "热卖"
}

/*
    imgUrl:     a.box-img的img的src
    name:       span.goods-name的内容
    desc:       span.goods-desc的内容
    price:      span.goods-price i .nextSibling的data
    red:        span.product-sign的内容
*/


// 批量拿数据
var arr = [];
var lis = $0.querySelectorAll("li");
for (var i = 0; i < lis.length; i++) {
    var o1 = {}
    var li = lis[i];
    o1.imgUrl = li.querySelector("a.box-img img").src;
    o1.name = li.querySelector('span.goods-name').innerText;
    o1.desc = li.querySelector('span.goods-desc').innerText;
    o1.price = li.querySelector('span.goods-price i').nextSibling.data;
    if(li.querySelector('span.product-sign')){
        o1.red = li.querySelector('span.product-sign').innerText;
    }else{
        o1.red = '';
    }
    // console.log(o1);
    arr.push(o1);
}
// // console.log(arr);
var jsonStr = JSON.stringify(arr);
console.log(jsonStr);